/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author GilJSA
 */
@Entity
@Table(name = "subsector")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Subsector.findAll", query = "SELECT s FROM Subsector s"),
    @NamedQuery(name = "Subsector.findByIdSubsector", query = "SELECT s FROM Subsector s WHERE s.idSubsector = :idSubsector"),
    @NamedQuery(name = "Subsector.findByNumeroSubsector", query = "SELECT s FROM Subsector s WHERE s.numeroSubsector = :numeroSubsector"),
    @NamedQuery(name = "Subsector.findByTipoSubsector", query = "SELECT s FROM Subsector s WHERE s.tipoSubsector = :tipoSubsector")})
public class Subsector implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idSubsector")
    private Integer idSubsector;
    @Basic(optional = false)
    @NotNull
    @Column(name = "numeroSubsector")
    private int numeroSubsector;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "tipoSubsector")
    private String tipoSubsector;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "subsectoridSubsector")
    private Collection<Tipomedicion> tipomedicionCollection;

    public Subsector() {
    }

    public Subsector(Integer idSubsector) {
        this.idSubsector = idSubsector;
    }

    public Subsector(Integer idSubsector, int numeroSubsector, String tipoSubsector) {
        this.idSubsector = idSubsector;
        this.numeroSubsector = numeroSubsector;
        this.tipoSubsector = tipoSubsector;
    }

    public Integer getIdSubsector() {
        return idSubsector;
    }

    public void setIdSubsector(Integer idSubsector) {
        this.idSubsector = idSubsector;
    }

    public int getNumeroSubsector() {
        return numeroSubsector;
    }

    public void setNumeroSubsector(int numeroSubsector) {
        this.numeroSubsector = numeroSubsector;
    }

    public String getTipoSubsector() {
        return tipoSubsector;
    }

    public void setTipoSubsector(String tipoSubsector) {
        this.tipoSubsector = tipoSubsector;
    }

    @XmlTransient
    public Collection<Tipomedicion> getTipomedicionCollection() {
        return tipomedicionCollection;
    }

    public void setTipomedicionCollection(Collection<Tipomedicion> tipomedicionCollection) {
        this.tipomedicionCollection = tipomedicionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSubsector != null ? idSubsector.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Subsector)) {
            return false;
        }
        Subsector other = (Subsector) object;
        if ((this.idSubsector == null && other.idSubsector != null) || (this.idSubsector != null && !this.idSubsector.equals(other.idSubsector))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Subsector[ idSubsector=" + idSubsector + " ]";
    }
    
}
